<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<!--
  1.插槽的基本使用 <slot></slot>
  2.插槽的默认值 <slot><button>按钮</button></slot>
  3.如果有多个值同时放入组件中进行替换时，一起作为替换元素
-->

<div id="app">
  <cpn></cpn>
  <cpn><span>哈哈哈</span></cpn>
  <cpn><i>呵呵呵</i></cpn>
  <cpn>
    <i>呵呵呵</i>
    <div>我是div元素</div>
    <p>我是p元素</p>
  </cpn>
</div>

<template id="cpn">
  <div>
    <h2>我是标题</h2>
    <p>我是组件</p>
    <slot><button>按钮</button></slot>
  </div>
</template>

<script src="../js/vue.js"></script>
<script>
  const app = new Vue({
    el: '#app',
    data: {
      message: '你好'
    },
    components: {
      cpn: {
        template: '#cpn'
      }
    }
  });
</script>
</body>
</html>